const status: {
  state: { num: number }
  actions: { add1: Function; add10: Function }
  actionName: {}
  asyncActions: {
    asyncAdd10: Function
  }
} = {
  state: {
    num: 20,
  },
  actions: {
    add1(state: { num: number }, action: { type: string }) {
      state.num++
    },
    add10(state: { num: number }, action: { type: string; val: number }) {
      state.num += action.val
    },
  },
  // 异步处理数据
  asyncActions: {
    asyncAdd10(dispatch: Function) {
      setTimeout(() => {
        dispatch({ type: 'add10', val: 10 })
      }, 1000)
    },
  },
  // 名字的统一化管理
  actionName: {},
}
let actionName = {}
for (let key in status.actions) {
  actionName[key] = key
}
status.actionName = actionName

export default status
